<template>

</template>

<script>
function noop() {}

export default {
  name: "ElUpload",
  
  provide() {
    return {
      uploader: this
    }
  },
  
  inject: {
    elForm: {
      default: ''
    }
  },
  
  props: {
    action: {
      type: String,
      required: true
    },
    // 设置上传的请求头部
    headers: {
      type: Object,
      default() {
        return {}
      }
    },
    // 上传时附带的额外参数
    data: Object,
    // 是否支持多选文件
    multiple: Boolean,
    // 上传的文件字段名
    name: {
      type: String,
      default: 'file'
    },
    drag: Boolean,
    dragger: Boolean,
    withCredentials: Boolean,
    showFileList: {
      type: Boolean,
      default: true
    },
    accept: String,
    //
    type: {
      type: String,
      default: 'select'
    },
    beforeUpload: Function,
    beforeRemove: Function,
    onRemove: {
      type: Function,
      default: noop
    },
    onChange: {
      type: Function,
      default: noop
    },
    // 点击文件列表中已上传的文件时的钩子 function(file)
    onPreview: {
      type: Function,
      default: noop
    },
    // 文件上传成功时的钩子 function(response, file, fileList)
    onSuccess: {
      type: Function,
      default: noop
    },
    // 文件上传时的钩子 function(event, file, fileList)
    onProgress: {
      type: Function,
      default: noop
    },
    // 上传失败时的钩子 function(err, file, fileList)
    onError: {
      type: Function,
      default: noop
    },
    fileList: {
      type: Array,
      default() {
        return [];
      }
    },
    // 是否在选取文件后立即进行上传
    autoUpload: {
      type: Boolean,
      default: true
    },
    listType: {
      type: String,
      default: 'text' //text, picture,picture-card
    },
    httpRequest: Function,
    disabled: Boolean,
    limit: Number,
    // 文件超出个数限制时的钩子 function(files, fileList)
    onExceed: {
      type: Function,
      default: noop
    }
  },
  
  data() {
    return {
      uploadFiles: [],
      dragOver: false,
      draging: false,
      tempIndex: 1
    }
  },
  
  computed: {
    uploadDisabled() {
      return this.disabled || (this.elForm || {}).disabled;
    }
  },
  
  watch: {
    listType(type) {
      if (type === 'picture-card' || type === 'picture') {
      
      }
    }
  }
}
</script>

<style scoped>

</style>